package com.kafka.web;

import com.kafka.danYiMessage.shoudong.ShouDongProvider;
import com.kafka.testp.KafKaProvider;
import com.kafka.danYiMessage.yibu.KafKaYIbuProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.UUID;
import java.util.concurrent.ExecutionException;

/**
 * 作者: LCG
 * 日期: 2020/6/18 23:45
 * 描述:
 */

@RestController
public class TestKafKaContro {

    @Autowired
    private KafKaProvider kafKaProvider;

    @Autowired
    KafKaYIbuProvider kafKaYIbuProvider;

    @RequestMapping("/testKa")
    public void testKa(){
        kafKaProvider.send();
    }

    /**
     * 测试发送异步消息
     */
    @RequestMapping("/tongbu")
    public void tongbu() throws ExecutionException, InterruptedException {
       for (int i=0;i<2;i++){
           kafKaYIbuProvider.send(UUID.randomUUID().toString()+"=>"+i);
       }
    }


    /**
     * 测试手动消费确认
     */
    @Autowired
    private ShouDongProvider shouDongProvider;

    @RequestMapping("/test04")
    public void test04(){
            shouDongProvider.send();
    }
}
